package com.wcp.web.tools;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/**
 * 製作WCP配置文件的增量升級包
 * 
 * @author macpl
 *
 */
public class GenerateChecksXml {

	public static void main(String[] args) throws IOException {
		System.out.println("启动");
		List<File> fullXmls = new ArrayList<>();
		// ---------------------------------------------------------------------
		String path = "D:\\JavaWorkspace\\workspace\\WTS-trunk\\wts-web\\src\\main";
		fullXmls.add(new File(path + "\\resources\\WcpInterConfig.xml"));
		fullXmls.add(new File(path + "\\resources\\WcpWebConfig.xml"));
		// ----------------------------------------------------------------------
		// 1.读取完整配置文件(多个)
		System.out.println("加载全部配置文件中...");
		Map<String, Element> elementMaps = new HashMap<>();
		for (File file : fullXmls) {
			Document document = Jsoup.parse(file, "utf-8");
			Elements elements = document.getElementsByTag("parameter");
			for (Element node : elements) {
				elementMaps.put(node.attr("name"), node);
				//<parameter versions='0.0.1'>config.sys.foot</parameter>
				System.out.println("<parameter versions='0.0.1'>"+node.attr("name")+"</parameter>");
			}
		}
		System.out.println("加载全部配置文件" + elementMaps.size());
	}

	

}
